package cn.com.wdjedu.androidapp.wjeduandroid.ui.introduceui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ProgressBar;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.com.wdjedu.androidapp.wjeduandroid.R;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.MvpFragment;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.introduce.introducePresenter;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.introduce.introduceBean;
import cn.com.wdjedu.androidapp.wjeduandroid.mvp.introduce.introduceview;
import cn.com.wdjedu.androidapp.wjeduandroid.ui.mainfragment.MainBean;

/**
 * 基础课程页面
 */
public class BasicCoursesFragment extends MvpFragment<introducePresenter> implements introduceview {
    @BindView(R.id.empty)
    TextView mEmpty;
    @BindView(R.id.listView)
    GridView mGridview;
    @BindView(R.id.progressbar)
    ProgressBar mProgressbar;
    List<MainBean.CourseBean.ContentBean> lists=new ArrayList<>();
    private VideoGridViewAdapter adtper;



    @Override
    protected introducePresenter createPresenter() {
        return new introducePresenter(this);
    }

    @Override
    protected void lazyLoad() {

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        super.onCreateView(inflater,container,savedInstanceState);
        View view = inflater.inflate(R.layout.gridview_layout, null);
        ButterKnife.bind(this, view);
        initData();
        return view;
    }

    private void initData() {
//        MainBean.VideosBean a;
//        for (int i = 0; i < 8; i++) {
//            a = new MainBean.VideosBean();
//            a.setUnit_name("第一单元");
//            a.setName("Java发展历史-" + i);
//            if (i == 2) {
//                a.setName("Java编程环境配置");
//            }
//            if (i > 2) {
//                a.setName("Java数据类型-" + i);
//            }
//            lists.add(a);
//        }
        mvpPresenter.queryIntroduceData(2);
        adtper=new VideoGridViewAdapter(mContext, R.layout.activity_index_gallery_item, lists);
        mGridview.setAdapter(adtper);
    }

    @Override
    public void queryNewIntroduceData(introduceBean introBean) {
        lists.clear();
        lists.addAll(introBean.getLists());
        adtper.notifyDataSetChanged();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showError(String error) {

    }
}
